<?php

namespace App\Repositories\Transformers;

use App\Models\VolunteerForm;
use League\Fractal\TransformerAbstract;

class VolunteerFormTransformer extends TransformerAbstract
{
    public function transform(VolunteerForm $volunteerForm)
    {
        $volunteerActivity = $volunteerForm->activity;

        if ($volunteerActivity) {
            
            return [
                'id' => $volunteerActivity->id,
                'title' => $volunteerActivity->title,
                'image' => $volunteerActivity->image,
                'activity_time_start' => $volunteerActivity->activity_time_start,
                'activity_time_end' => $volunteerActivity->activity_time_end,
                'limit_count' => $volunteerActivity->limit_count,
                'volunteer_form_count' => $volunteerForm->volunteer_form_count ?? 0,
                'audit_status' => $volunteerForm->audit_status,
                'created_at' => $volunteerActivity->created_at != null ? $volunteerActivity->created_at->toDateTimeString() : null,
            ];
        } else {
            return [];
        }
    }
}
